3.1.80 \(\int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx\) [80]

3.1.80.1 Optimal result
3.1.80.2 Mathematica [C] (verified)
3.1.80.3 Rubi [A] (verified)
3.1.80.4 Maple [A] (verified)
3.1.80.5 Fricas [A] (verification not implemented)
3.1.80.6 Sympy [C] (verification not implemented)
3.1.80.7 Maxima [A] (verification not implemented)
3.1.80.8 Giac [B] (verification not implemented)
3.1.80.9 Mupad [B] (verification not implemented)

3.1.80.1 Optimal result

Integrand size = 33, antiderivative size = 140 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=-\frac {\left (c^2 C-2 B c d-C d^2-A \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}+\frac {\left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{\left (c^2+d^2\right )^2 f}-\frac {c^2 C-B c d+A d^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))} \]

output
-(c^2*C-2*B*c*d-C*d^2-A*(c^2-d^2))*x/(c^2+d^2)^2+(2*c*(A-C)*d-B*(c^2-d^2)) 
*ln(c*cos(f*x+e)+d*sin(f*x+e))/(c^2+d^2)^2/f+(-A*d^2+B*c*d-C*c^2)/d/(c^2+d 
^2)/f/(c+d*tan(f*x+e))
 
3.1.80.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 2.71 (sec) , antiderivative size = 207, normalized size of antiderivative = 1.48 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\frac {B ((-i c-d) \log (i-\tan (e+f x))+i (c+i d) \log (i+\tan (e+f x))+2 d \log (c+d \tan (e+f x)))}{c^2+d^2}-\frac {2 C}{c+d \tan (e+f x)}+(B c+(-A+C) d) \left (\frac {i \log (i-\tan (e+f x))}{(c+i d)^2}-\frac {i \log (i+\tan (e+f x))}{(c-i d)^2}+\frac {2 d \left (-2 c \log (c+d \tan (e+f x))+\frac {c^2+d^2}{c+d \tan (e+f x)}\right )}{\left (c^2+d^2\right )^2}\right )}{2 d f} \]

input
Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x])^2,x 
]
 
output
((B*(((-I)*c - d)*Log[I - Tan[e + f*x]] + I*(c + I*d)*Log[I + Tan[e + f*x] 
] + 2*d*Log[c + d*Tan[e + f*x]]))/(c^2 + d^2) - (2*C)/(c + d*Tan[e + f*x]) 
 + (B*c + (-A + C)*d)*((I*Log[I - Tan[e + f*x]])/(c + I*d)^2 - (I*Log[I + 
Tan[e + f*x]])/(c - I*d)^2 + (2*d*(-2*c*Log[c + d*Tan[e + f*x]] + (c^2 + d 
^2)/(c + d*Tan[e + f*x])))/(c^2 + d^2)^2))/(2*d*f)
 
3.1.80.3 Rubi [A] (verified)

Time = 0.61 (sec) , antiderivative size = 151, normalized size of antiderivative = 1.08, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.182, Rules used = {3042, 4111, 3042, 4014, 3042, 4013}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {A+B \tan (e+f x)+C \tan (e+f x)^2}{(c+d \tan (e+f x))^2}dx\)

\(\Big \downarrow \) 4111

\(\displaystyle \frac {\int \frac {A c-C c+B d+(B c-(A-C) d) \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {A c-C c+B d+(B c-(A-C) d) \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}\)

\(\Big \downarrow \) 4014

\(\displaystyle \frac {\frac {\left (2 c d (A-C)-B \left (c^2-d^2\right )\right ) \int \frac {d-c \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {x \left (-A \left (c^2-d^2\right )-2 B c d+c^2 C-C d^2\right )}{c^2+d^2}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {\left (2 c d (A-C)-B \left (c^2-d^2\right )\right ) \int \frac {d-c \tan (e+f x)}{c+d \tan (e+f x)}dx}{c^2+d^2}-\frac {x \left (-A \left (c^2-d^2\right )-2 B c d+c^2 C-C d^2\right )}{c^2+d^2}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}\)

\(\Big \downarrow \) 4013

\(\displaystyle \frac {\frac {\left (2 c d (A-C)-B \left (c^2-d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{f \left (c^2+d^2\right )}-\frac {x \left (-A \left (c^2-d^2\right )-2 B c d+c^2 C-C d^2\right )}{c^2+d^2}}{c^2+d^2}-\frac {A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}\)

input
Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x])^2,x]
 
output
(-(((c^2*C - 2*B*c*d - C*d^2 - A*(c^2 - d^2))*x)/(c^2 + d^2)) + ((2*c*(A - 
 C)*d - B*(c^2 - d^2))*Log[c*Cos[e + f*x] + d*Sin[e + f*x]])/((c^2 + d^2)* 
f))/(c^2 + d^2) - (c^2*C - B*c*d + A*d^2)/(d*(c^2 + d^2)*f*(c + d*Tan[e + 
f*x]))
 

3.1.80.3.1 Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4013
Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)* 
(x_)]), x_Symbol] :> Simp[(c/(b*f))*Log[RemoveContent[a*Cos[e + f*x] + b*Si 
n[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && 
 NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]
 

rule 4014
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[(a*c + b*d)*(x/(a^2 + b^2)), x] + Simp[(b*c - a 
*d)/(a^2 + b^2)   Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x] /; 
FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && N 
eQ[a*c + b*d, 0]
 

rule 4111
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + 
 (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(A*b^2 - 
 a*b*B + a^2*C)*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1)*(a^2 + b^2))), x 
] + Simp[1/(a^2 + b^2)   Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[b*B + a*(A - 
 C) - (A*b - a*B - b*C)*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, e, f, A, B 
, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && LtQ[m, -1] && NeQ[a^2 + b^2, 0 
]
 
3.1.80.4 Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 173, normalized size of antiderivative = 1.24

method result size
derivativedivides \(\frac {\frac {\frac {\left (-2 A d c +B \,c^{2}-d^{2} B +2 C c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,c^{2}-A \,d^{2}+2 B c d -c^{2} C +C \,d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}-\frac {A \,d^{2}-B c d +c^{2} C}{\left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )}+\frac {\left (2 A d c -B \,c^{2}+d^{2} B -2 C c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}}{f}\) \(173\)
default \(\frac {\frac {\frac {\left (-2 A d c +B \,c^{2}-d^{2} B +2 C c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,c^{2}-A \,d^{2}+2 B c d -c^{2} C +C \,d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}-\frac {A \,d^{2}-B c d +c^{2} C}{\left (c^{2}+d^{2}\right ) d \left (c +d \tan \left (f x +e \right )\right )}+\frac {\left (2 A d c -B \,c^{2}+d^{2} B -2 C c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{\left (c^{2}+d^{2}\right )^{2}}}{f}\) \(173\)
norman \(\frac {\frac {c \left (A \,c^{2}-A \,d^{2}+2 B c d -c^{2} C +C \,d^{2}\right ) x}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {d \left (A \,c^{2}-A \,d^{2}+2 B c d -c^{2} C +C \,d^{2}\right ) x \tan \left (f x +e \right )}{c^{4}+2 c^{2} d^{2}+d^{4}}-\frac {A \,d^{2}-B c d +c^{2} C}{\left (c^{2}+d^{2}\right ) d f}}{c +d \tan \left (f x +e \right )}+\frac {\left (2 A d c -B \,c^{2}+d^{2} B -2 C c d \right ) \ln \left (c +d \tan \left (f x +e \right )\right )}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {\left (2 A d c -B \,c^{2}+d^{2} B -2 C c d \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}\) \(260\)
parallelrisch \(-\frac {2 A \,c^{2} d^{2}+2 A x \tan \left (f x +e \right ) d^{4} f -2 B \,c^{3} d -2 B c \,d^{3}+2 C \,c^{2} d^{2}+2 c^{4} C +2 A \,d^{4}-2 C x \tan \left (f x +e \right ) d^{4} f -2 A x \,c^{3} d f +2 A x c \,d^{3} f -4 B x \,c^{2} d^{2} f +2 C x \,c^{3} d f -2 C x c \,d^{3} f +2 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) c \,d^{3}-4 A \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) c \,d^{3}-B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) c^{2} d^{2}+2 B \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) c^{2} d^{2}-2 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) c \,d^{3}+4 C \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) c \,d^{3}-2 A x \tan \left (f x +e \right ) c^{2} d^{2} f -4 B x \tan \left (f x +e \right ) c \,d^{3} f +2 C x \tan \left (f x +e \right ) c^{2} d^{2} f +B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) \tan \left (f x +e \right ) d^{4}-2 B \ln \left (c +d \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) d^{4}+2 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c^{2} d^{2}-4 A \ln \left (c +d \tan \left (f x +e \right )\right ) c^{2} d^{2}-B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c^{3} d +B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c \,d^{3}+2 B \ln \left (c +d \tan \left (f x +e \right )\right ) c^{3} d -2 B \ln \left (c +d \tan \left (f x +e \right )\right ) c \,d^{3}-2 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) c^{2} d^{2}+4 C \ln \left (c +d \tan \left (f x +e \right )\right ) c^{2} d^{2}}{2 \left (c +d \tan \left (f x +e \right )\right ) f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right ) d}\) \(551\)
risch \(\frac {4 i C c d e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {x A}{2 i c d -c^{2}+d^{2}}+\frac {x C}{2 i c d -c^{2}+d^{2}}+\frac {2 i A \,d^{2}}{\left (i d +c \right ) f \left (-i d +c \right )^{2} \left (-i d \,{\mathrm e}^{2 i \left (f x +e \right )}+c \,{\mathrm e}^{2 i \left (f x +e \right )}+i d +c \right )}-\frac {4 i A c d e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}+\frac {i x B}{2 i c d -c^{2}+d^{2}}-\frac {2 i B x \,d^{2}}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {4 i C x c d}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {2 i B \,c^{2} e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {2 i B \,d^{2} e}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}+\frac {2 i c^{2} C}{\left (i d +c \right ) f \left (-i d +c \right )^{2} \left (-i d \,{\mathrm e}^{2 i \left (f x +e \right )}+c \,{\mathrm e}^{2 i \left (f x +e \right )}+i d +c \right )}-\frac {2 i B c d}{\left (i d +c \right ) f \left (-i d +c \right )^{2} \left (-i d \,{\mathrm e}^{2 i \left (f x +e \right )}+c \,{\mathrm e}^{2 i \left (f x +e \right )}+i d +c \right )}+\frac {2 i B \,c^{2} x}{c^{4}+2 c^{2} d^{2}+d^{4}}-\frac {4 i A x c d}{c^{4}+2 c^{2} d^{2}+d^{4}}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) A d c}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) B \,c^{2}}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) d^{2} B}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i d +c}{i d -c}\right ) C c d}{f \left (c^{4}+2 c^{2} d^{2}+d^{4}\right )}\) \(660\)

input
int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x,method=_RETURNVER 
BOSE)
 
output
1/f*(1/(c^2+d^2)^2*(1/2*(-2*A*c*d+B*c^2-B*d^2+2*C*c*d)*ln(1+tan(f*x+e)^2)+ 
(A*c^2-A*d^2+2*B*c*d-C*c^2+C*d^2)*arctan(tan(f*x+e)))-(A*d^2-B*c*d+C*c^2)/ 
(c^2+d^2)/d/(c+d*tan(f*x+e))+(2*A*c*d-B*c^2+B*d^2-2*C*c*d)/(c^2+d^2)^2*ln( 
c+d*tan(f*x+e)))
 
3.1.80.5 Fricas [A] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 256, normalized size of antiderivative = 1.83 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=-\frac {2 \, C c^{2} d - 2 \, B c d^{2} + 2 \, A d^{3} - 2 \, {\left ({\left (A - C\right )} c^{3} + 2 \, B c^{2} d - {\left (A - C\right )} c d^{2}\right )} f x + {\left (B c^{3} - 2 \, {\left (A - C\right )} c^{2} d - B c d^{2} + {\left (B c^{2} d - 2 \, {\left (A - C\right )} c d^{2} - B d^{3}\right )} \tan \left (f x + e\right )\right )} \log \left (\frac {d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - 2 \, {\left (C c^{3} - B c^{2} d + A c d^{2} + {\left ({\left (A - C\right )} c^{2} d + 2 \, B c d^{2} - {\left (A - C\right )} d^{3}\right )} f x\right )} \tan \left (f x + e\right )}{2 \, {\left ({\left (c^{4} d + 2 \, c^{2} d^{3} + d^{5}\right )} f \tan \left (f x + e\right ) + {\left (c^{5} + 2 \, c^{3} d^{2} + c d^{4}\right )} f\right )}} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x, algorithm= 
"fricas")
 
output
-1/2*(2*C*c^2*d - 2*B*c*d^2 + 2*A*d^3 - 2*((A - C)*c^3 + 2*B*c^2*d - (A - 
C)*c*d^2)*f*x + (B*c^3 - 2*(A - C)*c^2*d - B*c*d^2 + (B*c^2*d - 2*(A - C)* 
c*d^2 - B*d^3)*tan(f*x + e))*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e) 
+ c^2)/(tan(f*x + e)^2 + 1)) - 2*(C*c^3 - B*c^2*d + A*c*d^2 + ((A - C)*c^2 
*d + 2*B*c*d^2 - (A - C)*d^3)*f*x)*tan(f*x + e))/((c^4*d + 2*c^2*d^3 + d^5 
)*f*tan(f*x + e) + (c^5 + 2*c^3*d^2 + c*d^4)*f)
 
3.1.80.6 Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.92 (sec) , antiderivative size = 4396, normalized size of antiderivative = 31.40 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=\text {Too large to display} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e))**2,x)
 
output
Piecewise((zoo*x*(A + B*tan(e) + C*tan(e)**2)/tan(e)**2, Eq(c, 0) & Eq(d, 
0) & Eq(f, 0)), ((A*x + B*log(tan(e + f*x)**2 + 1)/(2*f) - C*x + C*tan(e + 
 f*x)/f)/c**2, Eq(d, 0)), (-A*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)** 
2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I*A*f*x*tan(e + f*x)/(4*d**2*f 
*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + A*f*x/(4*d**2*f*t 
an(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - A*tan(e + f*x)/(4*d 
**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I*A/(4*d** 
2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + I*B*f*x*tan(e 
+ f*x)**2/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) 
+ 2*B*f*x*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) 
 - 4*d**2*f) - I*B*f*x/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) 
 - 4*d**2*f) + I*B*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan 
(e + f*x) - 4*d**2*f) + C*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)**2 - 
8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - 2*I*C*f*x*tan(e + f*x)/(4*d**2*f*tan 
(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - C*f*x/(4*d**2*f*tan(e 
 + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) - 3*C*tan(e + f*x)/(4*d** 
2*f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f) + 2*I*C/(4*d**2* 
f*tan(e + f*x)**2 - 8*I*d**2*f*tan(e + f*x) - 4*d**2*f), Eq(c, -I*d)), (-A 
*f*x*tan(e + f*x)**2/(4*d**2*f*tan(e + f*x)**2 + 8*I*d**2*f*tan(e + f*x) - 
 4*d**2*f) - 2*I*A*f*x*tan(e + f*x)/(4*d**2*f*tan(e + f*x)**2 + 8*I*d**...
 
3.1.80.7 Maxima [A] (verification not implemented)

Time = 0.34 (sec) , antiderivative size = 205, normalized size of antiderivative = 1.46 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\frac {2 \, {\left ({\left (A - C\right )} c^{2} + 2 \, B c d - {\left (A - C\right )} d^{2}\right )} {\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {2 \, {\left (B c^{2} - 2 \, {\left (A - C\right )} c d - B d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {{\left (B c^{2} - 2 \, {\left (A - C\right )} c d - B d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {2 \, {\left (C c^{2} - B c d + A d^{2}\right )}}{c^{3} d + c d^{3} + {\left (c^{2} d^{2} + d^{4}\right )} \tan \left (f x + e\right )}}{2 \, f} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x, algorithm= 
"maxima")
 
output
1/2*(2*((A - C)*c^2 + 2*B*c*d - (A - C)*d^2)*(f*x + e)/(c^4 + 2*c^2*d^2 + 
d^4) - 2*(B*c^2 - 2*(A - C)*c*d - B*d^2)*log(d*tan(f*x + e) + c)/(c^4 + 2* 
c^2*d^2 + d^4) + (B*c^2 - 2*(A - C)*c*d - B*d^2)*log(tan(f*x + e)^2 + 1)/( 
c^4 + 2*c^2*d^2 + d^4) - 2*(C*c^2 - B*c*d + A*d^2)/(c^3*d + c*d^3 + (c^2*d 
^2 + d^4)*tan(f*x + e)))/f
 
3.1.80.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 291 vs. \(2 (140) = 280\).

Time = 0.54 (sec) , antiderivative size = 291, normalized size of antiderivative = 2.08 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\frac {2 \, {\left (A c^{2} - C c^{2} + 2 \, B c d - A d^{2} + C d^{2}\right )} {\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac {{\left (B c^{2} - 2 \, A c d + 2 \, C c d - B d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac {2 \, {\left (B c^{2} d - 2 \, A c d^{2} + 2 \, C c d^{2} - B d^{3}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{4} d + 2 \, c^{2} d^{3} + d^{5}} + \frac {2 \, {\left (B c^{2} d^{2} \tan \left (f x + e\right ) - 2 \, A c d^{3} \tan \left (f x + e\right ) + 2 \, C c d^{3} \tan \left (f x + e\right ) - B d^{4} \tan \left (f x + e\right ) - C c^{4} + 2 \, B c^{3} d - 3 \, A c^{2} d^{2} + C c^{2} d^{2} - A d^{4}\right )}}{{\left (c^{4} d + 2 \, c^{2} d^{3} + d^{5}\right )} {\left (d \tan \left (f x + e\right ) + c\right )}}}{2 \, f} \]

input
integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x, algorithm= 
"giac")
 
output
1/2*(2*(A*c^2 - C*c^2 + 2*B*c*d - A*d^2 + C*d^2)*(f*x + e)/(c^4 + 2*c^2*d^ 
2 + d^4) + (B*c^2 - 2*A*c*d + 2*C*c*d - B*d^2)*log(tan(f*x + e)^2 + 1)/(c^ 
4 + 2*c^2*d^2 + d^4) - 2*(B*c^2*d - 2*A*c*d^2 + 2*C*c*d^2 - B*d^3)*log(abs 
(d*tan(f*x + e) + c))/(c^4*d + 2*c^2*d^3 + d^5) + 2*(B*c^2*d^2*tan(f*x + e 
) - 2*A*c*d^3*tan(f*x + e) + 2*C*c*d^3*tan(f*x + e) - B*d^4*tan(f*x + e) - 
 C*c^4 + 2*B*c^3*d - 3*A*c^2*d^2 + C*c^2*d^2 - A*d^4)/((c^4*d + 2*c^2*d^3 
+ d^5)*(d*tan(f*x + e) + c)))/f
 
3.1.80.9 Mupad [B] (verification not implemented)

Time = 10.55 (sec) , antiderivative size = 184, normalized size of antiderivative = 1.31 \[ \int \frac {A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx=\frac {\ln \left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (-B\,c^2+\left (2\,A-2\,C\right )\,c\,d+B\,d^2\right )}{f\,\left (c^4+2\,c^2\,d^2+d^4\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (A-C+B\,1{}\mathrm {i}\right )}{2\,f\,\left (-c^2\,1{}\mathrm {i}+2\,c\,d+d^2\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (A\,1{}\mathrm {i}+B-C\,1{}\mathrm {i}\right )}{2\,f\,\left (-c^2+c\,d\,2{}\mathrm {i}+d^2\right )}-\frac {C\,c^2-B\,c\,d+A\,d^2}{d\,f\,\left (c^2+d^2\right )\,\left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )} \]

input
int((A + B*tan(e + f*x) + C*tan(e + f*x)^2)/(c + d*tan(e + f*x))^2,x)
 
output
(log(c + d*tan(e + f*x))*(B*d^2 - B*c^2 + c*d*(2*A - 2*C)))/(f*(c^4 + d^4 
+ 2*c^2*d^2)) - (log(tan(e + f*x) - 1i)*(A + B*1i - C))/(2*f*(2*c*d - c^2* 
1i + d^2*1i)) - (log(tan(e + f*x) + 1i)*(A*1i + B - C*1i))/(2*f*(c*d*2i - 
c^2 + d^2)) - (A*d^2 + C*c^2 - B*c*d)/(d*f*(c^2 + d^2)*(c + d*tan(e + f*x) 
))